package com.wen.titledemo.activity;

import android.view.View;
import android.widget.Toast;

import com.wen.titledemo.R;
import com.wen.titledemo.app.AppActivity;
import com.wen.titledemo.app.title.DefTitleBar;

public class MainActivity extends AppActivity {

    @Override
    protected void initTitle(DefTitleBar titleBar) {
        titleBar.setTitle("测试标题");
    }

    @Override
    protected Object getContentLayout() {
        return R.layout.activity_main;
    }

    /**
     * 隐藏返回按钮
     */
    public void hideTitle(View view) {
        mTitleBar.clearBackClick();
    }

    /**
     * 添加一个右边图标
     */
    public void addOneIcon(View view) {
        mTitleBar.addRightIcon(R.mipmap.ic_launcher, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getAppActivity(), "点击事件", Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     * 添加多个右边图标
     */
    public void addMoreIcon(View view) {
        int[] icons = {R.mipmap.ic_launcher, R.mipmap.ic_launcher_round};
        View.OnClickListener[] clicks = {new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getAppActivity(), "点击事件", Toast.LENGTH_SHORT).show();
            }
        }, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getAppActivity(), "点击事件", Toast.LENGTH_SHORT).show();
            }
        }};
        mTitleBar.addRightIcons(icons, clicks);
    }

    @Override
    protected boolean isExit() {
        return true;
    }
}
